<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子组件传给父组件的值  其他子组件会不会发生改变</title>
</head>
<body>
    <div id="app">
        {{msg}}
        <html-a @child-change="parent"></html-a>
        <html-b :text="msg"></html-b>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        //去除警告
        Vue.config.productionTip = false; 

        let vue = new Vue({
            el:"#app",
            data:{
                msg:"tianyi"
            },
            methods: {
                parent(name){
                    this.msg = name;
                    console.log('从子组件那里拿到的值'+name);
                }
            },
            components:{
                'html-a':{
                    data(){
                        return {
                            name:"子组件"
                        }
                    },
                    template:`
                        <div>
                            <p @click="childChange(name)">{{name}}</p>
                        </div>   
                    `,
                    methods: {
                        childChange(name){
                            //child-change  组件@child-change="";
                            this.$emit('child-change',name); 
                        }
                    },
                },
                'html-b':{
                    data(){
                        return {
                            name:"B子组件"
                        }
                    },
                    template:`
                        <div>
                            <p>{{text}}</p>
                        </div>   
                    `,
                    props:['text']
                }
            },
        })
    </script>
</body>
</html>